package com.payment.ktb.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.payment.ktb.R;
import com.payment.ktb.constants.ConstantsProfitType;
import com.payment.ktb.model.ProfitDetailEntity;
import com.payment.ktb.model.ProfitSumEntity;
import com.payment.ktb.utils.StringUtils;

import java.util.List;

/**
 * Created by admin on 2017/9/22.
 */

public class AdapterProfitSum extends BaseAdapter {

    private Context mContext;
    private List<ProfitSumEntity> listdatas;

    public AdapterProfitSum(Context mContext, List<ProfitSumEntity> listdatas) {
        this.mContext = mContext;
        this.listdatas = listdatas;
    }

    public AdapterProfitSum() {
    }

    @Override
    public int getCount() {
        return listdatas.size();
    }

    @Override
    public Object getItem(int i) {
        return listdatas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder viewHolder = null;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = View.inflate(mContext, R.layout.adapter_profitsum_item,null);
            viewHolder.tv_profitsum_profitDay = (TextView) view.findViewById(R.id.tv_profitsum_profitDay);
            viewHolder.tv_profitsum_stsStatus = (TextView) view.findViewById(R.id.tv_profitsum_stsStatus);
            viewHolder.tv_profitsum_profitPrice = (TextView) view.findViewById(R.id.tv_profitsum_profitPrice);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.tv_profitsum_profitDay.setText(listdatas.get(i).getProfitDay());
        viewHolder.tv_profitsum_profitPrice.setText("¥ " + StringUtils.handleFen2Yuan(listdatas.get(i).getProfitPrice()));
        //INIT(0, "未入账")
        //SUCC(2, "已入账")
        if (listdatas.get(i).getStsStatus() == 0) {
            viewHolder.tv_profitsum_stsStatus.setTextColor(mContext.getResources().getColor(R.color.red));
            viewHolder.tv_profitsum_stsStatus.setText("未入账");
        } else if (listdatas.get(i).getStsStatus() == 2) {
            viewHolder.tv_profitsum_stsStatus.setTextColor(mContext.getResources().getColor(R.color.green));
            viewHolder.tv_profitsum_stsStatus.setText("已入账");
        }

        return view;
    }


    class ViewHolder {

        TextView tv_profitsum_profitDay;
        TextView tv_profitsum_stsStatus;
        TextView tv_profitsum_profitPrice;

    }

}
